package com.woniu.cinema.service.impl;

import java.util.Arrays;
import java.util.List;

import com.woniu.cinema.dto.DynamicRequestMovieDto;
import com.woniu.cinema.vo.MovieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.woniu.cinema.mapper.MovieMapper;
import com.woniu.cinema.domain.Movie;
import com.woniu.cinema.service.MovieService;

/**
 * 影片信息Service业务层处理
 * 
 * @author yy
 * @date 2022-03-30
 */
@Service
public class MovieServiceImpl implements MovieService
{
    @Autowired
    private MovieMapper movieMapper;

    /**
     * 查询影片信息
     * 
     * @param movieId 影片信息ID
     * @return 影片信息
     */
    @Override
    public Movie selectMovieById(Integer movieId)
    {
        return movieMapper.selectMovieById(movieId);
    }

    /**
     * 查询影片信息列表
     * 
     * @param movie 影片信息
     * @return 影片信息
     */
    @Override
    public List<Movie> selectMovieList(Movie movie)
    {
        return movieMapper.selectMovieList(movie);
    }

    /**
     * 新增影片信息
     * 
     * @param movie 影片信息
     * @return 结果
     */
    @Override
    public int insertMovie(Movie movie)
    {
        return movieMapper.insertMovie(movie);
    }

    /**
     * 修改影片信息
     * 
     * @param movie 影片信息
     * @return 结果
     */
    @Override
    public int updateMovie(Movie movie)
    {
        return movieMapper.updateMovie(movie);
    }

    /**
     * 批量删除影片信息
     * 
     * @param movieIds 需要删除的影片信息ID
     * @return 结果
     */
    @Override
    public int deleteMovieByIds(Integer[] movieIds)
    {
        return movieMapper.deleteMovieByIds(movieIds);
    }

    /**
     * 删除影片信息信息
     * 
     * @param movieId 影片信息ID
     * @return 结果
     */
    @Override
    public int deleteMovieById(Integer movieId)
    {
        return movieMapper.deleteMovieById(movieId);
    }

    @Override
    public List<Movie> dynamiclist(DynamicRequestMovieDto movieDto) {


        return movieMapper.dynamiclist(movieDto);
    }

    @Override
    public MovieVo selectMovieVoById(Integer movieId) {

        return movieMapper.selectMovieVoById(movieId);

    }

    @Override
    public List<Movie> queryMoviesByCinemaId(Integer cinemaId) {

        return movieMapper.queryMoviesByCinemaId(cinemaId);


    }

    @Override
    public List<MovieVo> queryMovieById(Integer movieId) {

        if(movieId==-1){
            return movieMapper.selectAllMovieVo();
        }

        MovieVo movieVo = movieMapper.selectMovieVoById(movieId);

        return Arrays.asList(movieVo);

    }
}
